/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Monsters;

import IO.Utils;
import Map.Map;
import Map.MapUtils;
import Monsters.Monster;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author insane
 */
public class Monsters {

    public static void add(Map map, int count) throws FileNotFoundException, IOException, ClassNotFoundException {
        ArrayList<Monster> monsters = map.getMonster();
        if (monsters == null) {
            monsters = new ArrayList();
        }
        for (int i = 0; i < count; i++) {

            int[] position = MapUtils.getEmptyPosition(map);
            Monster ms = new Monster(true, 2, position[0], position[1], 0, 3, 15);
            ms.setName("monster " + i);
            ms.setColor(Utils.rand(1, 6));
            monsters.add(ms);
        }
        map.setMonster(monsters);
    }

    public void selection() {
    }

    public static void getMonsterToMap(Map map) throws FileNotFoundException, IOException, ClassNotFoundException {
        ArrayList<Monster> monsters = map.getMonster();
        if (monsters == null) {
            return;
        }
        Iterator<Monster> itr = monsters.iterator();
        while (itr.hasNext()) {
            Monster m = itr.next();
            m.analize();
            m.draw();
        }
    }
}
